Am I the only one this anal / obsessive about code? [closed]

Posted by Chris on Programmers See other posts from Programmers or by Chris
Published on 2012-11-14T01:50:04Z Indexed on 2012/11/14 5:12 UTC
Read the original article Hit count: 254

Filed under:

While writing a shared lock class for sql server for a web app tonight, I found myself writing in the code style below as I always do:

private bool acquired;
private bool disposed;
private TimeSpan timeout;
private string connectionString;
private Guid instance = Guid.NewGuid();
private Thread autoRenewThread;

Basically, whenever I'm declaring a group of variables or writing a sql statement or any coding activity involving multiple related lines, I always try to arrange them where possible so that they form a bell curve (imagine rotating the text 90deg CCW).

As an example of something that peeves the hell out of me, consider the following alternative:

private bool acquired;
private bool disposed;
private string connectionString;
private Thread autoRenewThread;
private Guid instance = Guid.NewGuid();
private TimeSpan timeout;

In the above example, declarations are grouped (arbitrarily) so that the primitive types appear at the top. When viewing the code in Visual Studio, primitive types are a different color than non-primitives, so the grouping makes sense visually, if for no other reason. But I don't like it because the right margin is less of an aesthetic curve. I've always chalked this up to being OCD or something, but at least in my mind, the code is "prettier". Am I the only one?

© Programmers or respective owner

Related posts about coding-style